﻿using B.S.DataBase.MyProject.Domain.Infrastructures;
using B.S.DataBase.MyProject.Domain.wdx;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Read.API.Appcation.Commands.FoundationCommand;
using MedicalPCTerminal.Read.API.Dtos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Read.API.Controllers
{
    /// <summary>
    /// 基础设置的控制器-查询
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class BasicSettingsController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public BasicSettingsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        #region 基础设置
        /// <summary>
        /// 查询基础设置的团队管理
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<TeamInfo>>> GetTeamInfo([FromQuery] TeamInfoQueryCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        /// <summary>
        /// 查询基础设置--团队管理的左侧树形
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<TeamInfoDto>>> GetTeamTree([FromQuery]QueryOrganizationListCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        ///查询基础设置--团队管理的左侧树形的点击事件
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<TeamInfo>>> GetTeamInfoById([FromQuery]GetTeamInfoByIdCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw;
            }
        }

        /// <summary>
        /// 查询基础设置--设备管理的分页列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<Device>> GetDeviceInfo([FromQuery]GetDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw;
            }
        }




       /// <summary>
       /// 基础设置-慢病指标查询
       /// </summary>
       /// <param name="request"></param>
       /// <returns></returns>
       [HttpGet]
        public async Task<APIResult<List<DiseaseIndicators>>> GetDiseaseIndicators([FromQuery]GetDiseaseIndicatorsCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        /// <summary>
        /// 基础设置-种病管理查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<DiseaseManagement>>> GetDiseaseManagement([FromQuery] GetDiseaseManagementCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }

        /// <summary>
        /// 基础设置-指标分类查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<IndexClass>>> GetIndexClass([FromQuery] GetIndexClassCommand request)
        {
            try
            {
                return await mediator.Send(request);    
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-指标定义查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<IndexDefine>>> GetIndexDefine([FromQuery] GetIndexDefineCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 基础设置-指标分类根据id反填查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<IndexClass>> GetIndexClassDetail([FromQuery] GetIndexClassDetailCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 基础设置-指标定义根据id反填查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<IndexDefine>> GetIndexDefineDetail([FromQuery] GetIndexDefineDetailCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 显示转诊配置
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Institution>>> GetInstitution([FromQuery]QueryInstitutionCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
       

        #endregion




    }



}
